package com.wang.bootbuilder.controller;

import com.wang.bootbuilder.annotation.HasPermission;
import com.wang.bootbuilder.annotation.LogAsp;
import com.wang.bootbuilder.entity.param.RoleParam;
import com.wang.bootbuilder.service.RoleService;
import com.wang.bootbuilder.tools.JsonResult;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
@RequestMapping("/manage/role")
@Api(value = "/manage/role", description = "处理角色相关请求的controller")
public class RoleController {

    @Autowired
    RoleService roleService;

    /*
    添加角色
     */
    @PostMapping("/add")
    public JsonResult addRole(@RequestBody RoleParam param) {
        JsonResult result = roleService.addRole(param.getRoleName());
        return result;
    }

    /*
    获取角色列表
     */
    @GetMapping("/list")
    // @HasPermission("4")
    public JsonResult getRolesList() {
        JsonResult result = roleService.getRolesList();
        return result;
    }

    /*
    更新角色(给角色设置权限)
     */
    @PostMapping("/update")
    public JsonResult updateRole(@RequestBody RoleParam param) {
        JsonResult result = roleService.updateRole(param);
        return result;
    }
}
